import{ createRouter,createWebHashHistory} from "vue-router"

// 同步引入 打包后会生成1个js文件(所有的路由都会被打包进去同一个js文件)和1个css文件(打包指令：npm run build)
import HomePage from "../views/Homepage.vue"
import UserCenter from "../views/UserCenter.vue"
import GoodsCart from "../views/GoodsCartPage.vue"

// 异步引入 打包后会生成多个js和css文件(每个路由单独打包生成一个css和一个js)
//         在切换文件请求数据时，只有首次会请求，后续将不会请求数据
// const HomePage = () => import("../views/HomePage.vue")
// const UserCenter = () => import("../views/UserCenter.vue")
// const GoodsCart = () => import("../views/GoodsCartPage.vue")

const router = createRouter({
    history:createWebHashHistory(),
    routes:[
        {
            path:"/home",
            component:HomePage
        },
        {
            path:"/user",
            component:UserCenter
        },
        {
            path:"/goods",
            component:GoodsCart
        },

    ]
})


// 导出路由
export default router;